<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<LINK rel="Bookmark" href="/favicon.ico" >
	<LINK rel="Shortcut Icon" href="/favicon.ico" />
	<title>修改</title>
</head>
<body>
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="formEdit">
		<input type="hidden" value="${r"${"}model.id${r"}"}" name="id">
	<#list modelColumns as item>
		<#if item.attrType == "Date">
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>${attrRemarks[item_index]}：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input class="Wdate input-text" value="<fmt:formatDate value="${r"${"}model.${item.attrName}${r"}"}" pattern="yyyy-MM-dd HH:mm:ss"/>" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" name="${item.attrName}" id="${item.attrName}">
			</div>
		</div>
		<#else>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>${attrRemarks[item_index]}：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" value="${r"${"}model.${item.attrName}${r"}"}" placeholder="" id="${item.attrName}" name="${item.attrName}">
			</div>
		</div>
		</#if>
	</#list>
		<div class="row cl">
			<div class="col-xs-6 col-sm-6 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="button" onclick="update()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
<script type="text/javascript">
	//禁用ajax缓存,需要请开启
	//$.ajaxSetup({cache:false});

	function update(){
		if(validateForm()){
			//此处为遮罩层
			var load_idx = layer.load(1, {shade: [0.1,'#fff']});

			$.post("update",$("#formEdit").serialize(),function(result){
				layer.close(load_idx);
				if(result.success){
					//如果想提供提示,应该使用回调的方式刷新页面
//					layer.msg('操作成功', {time: 1000, icon:6},function(){
//						parent.refresh();
//					});
					parent.refresh();
				}else{
					layer.msg(result.msg,{icon:5});
				}
			});
		}
	}
	function validateForm(){
		return $("#formEdit").validate({
			rules:{
		<#list modelColumns as item>
		${item.attrName}:{
					required:true
				}<#if item_has_next>,</#if>
		</#list>
			},
			onkeyup:false,
			focusCleanup:true,
			success:"valid"
		}).form();
	}
</script>
</body>
</html>